import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import axios from 'axios'

const url = 'http://geek.itheima.net/v1_0/channels'
const name = ref('')
const password = ref('')

export const useCounteStore = defineStore('counter', () =>{

  const count = ref(0)

  function increment(){
    count.value++
  }

  const doubleCount = computed(() => count.value * 2)

  const list = ref([])

  const getList = async() => {
    const response = await axios({
      method: 'get',
      url : url,
      headers: {
        'Content-Type': 'application/json'
      },
    })
    list.value = response.data.data
  }


  return {
    count,
    doubleCount,
    increment,
    list,
    getList
  }
})